package ee.parameterConverter.guice;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;

import ee.metadataUtils.guice.MetadataUtilsModule;
import ee.parameterConverter.ConverterResolver;
import ee.parameterConverter.GenericStringConverter;
import ee.parameterConverter.ParameterConverter;
import ee.parameterConverter.ParameterPropertyMetadata;
import ee.parameterConverter.TypeKindResolver;
import ee.parameterConverter.ValidationResultCollector;
import ee.parameterConverter.impl.GenericStringConverterImpl;
import ee.parameterConverter.impl.TypeKindResolverImpl;
import ee.parameterConverter.impl.ValidationResultCollectorImpl;

public class ParameterConverterModule extends AbstractModule {

	@Override
	protected void configure() {
		bind(TypeKindResolver.class).to(TypeKindResolverImpl.class).asEagerSingleton();
		
		bind(ValidationResultCollector.class).to(ValidationResultCollectorImpl.class);
		bind(GenericStringConverter.class).to(GenericStringConverterImpl.class);
		
		bind(ParameterConverter.class).to(GuiceParameterConverter.class);
		bind(ConverterResolver.class).to(GuiceConverterResolver.class);
		
		MetadataUtilsModule.bindAdapter(binder(), ParameterPropertyMetadata.class, GuiceParameterPropertyMetadata.class);
		
		bind(String.class).annotatedWith(Names.named("optionalAnnotationName")).toInstance("Optional");
	}

}
